<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 12-9-1
 * Time: 下午6:35
 * To change this template use File | Settings | File Templates.
 */
class comment extends MY_Model
{
    /**
     * 添加评论
     *
     * @param array $data
     * @return mixed
     */
    public function save(array $data)
    {
        $info = array(
            'resource_id' => $data['resource_id'],
            'title' => $data['title'],
            'content' => $data['content'],
            'user_id' => $data['user_id'],
            'username' => $data['username'],
        );

        $this->db->insert('comment', $info);
        return $this->db->insert_id();
    }

    /**
     * 删除评论
     *
     * @param $id
     * @return mixed
     */
    public function delete($id)
    {
        return $this->db->delete('comment', array('id' => $id));
    }
}
